//
//  UIBarButtonItem+Extension.swift
//  Home_school_晓林
//
//  Created by 张晓林 on 16/9/12.
//  Copyright © 2016年 张晓林. All rights reserved.
//

import UIKit

extension UIBarButtonItem {

    convenience init(image:String, HLImage:String, target:AnyObject?, action:Selector) {
        // 创建按钮
        let btn = UIButton(type:.custom)
        // 设置属性
        btn.bounds = CGRect(x: 0, y: 0, width: 19, height: 13)
        btn.setBackgroundImage(UIImage(named: image), for: .normal)
        btn.setBackgroundImage(UIImage(named: HLImage), for: .highlighted)
        
        btn.addTarget(target, action: action, for: .touchUpInside)
        // 调用自身的初始化方法来初始化
        self.init(customView: btn)
    }
    
    convenience init(image:String, title:String, target:AnyObject?, action:Selector) {
        // 创建按钮
        let btn = UIButton(type:.custom)
        // 设置属性
//        btn.bounds = CGRect(x: 0, y: 0, width: 160, height: 44)
        btn.setImage(UIImage(named:image), for: .normal)
        btn.setTitle(title, for: .normal)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 22)
        btn.setTitleColor(#colorLiteral(red: 1, green: 1, blue: 1, alpha: 1), for: .normal)
        btn.contentHorizontalAlignment = .left
        btn.addTarget(target, action: action, for: .touchUpInside)
        btn.sizeToFit()
        // 调用自身的初始化方法来初始化
        self.init(customView: btn)
    }
    
}
